1. Field of the Invention
The present invention relates to Firmware Over-The-Air (FOTA) updates. More particularly, the present invention relates to a method for efficient backup during a FOTA update.
2. Description of the Related Art
Mobile terminals are developed to provide wireless communication between users. As technology has advanced, mobile terminals now provide many additional features beyond simple telephone conversation. For example, mobile terminals are now able to provide additional functions such as an alarm, a Short Messaging Service (SMS), a Multimedia Message Service (MMS), E-mail, games, remote control of short range communication, an image capturing function using a mounted digital camera, a multimedia function for providing audio and video content, a scheduling function, and many more. With the plurality of features now provided, a mobile terminal has effectively become a necessity of daily life.
Software to control a mobile terminal is typically stored as firmware. Typically, in order to update the firmware, the user had to download an entire copy of the updated firmware, and then install the updated firmware on the mobile terminal. In many cases, the user had to download the updated firmware to a desktop or laptop computer to which the mobile terminal was attached, instead of controlling the updating process directly from the mobile terminal.
Recently, the concept of Firmware-Over-The-Air (FOTA) has been introduced. In this technique, an update package is delivered to the mobile terminal wirelessly. The update package includes a series of instructions which, when applied to the existing firmware, update the firmware to the newer version. An update client stored on the mobile terminal executes the instructions in the update package to modify the existing firmware and produce the updated version. Generally, the update package only includes the information needed to update the existing firmware to the new version. The update package does not include data corresponding to the portion of the firmware that is not being updated. As a result, the size of the update package is reduced.
However, problems may occur if a power loss occurs during the update process. The firmware is stored in non-volatile memory, usually either NAND flash or NOR flash. Flash memory is organized into blocks (also referred to as sectors) with a typical size between 64 KB and 256 KB. In order to modify any byte in a particular block, the entire block should be erased before the block can be written to. Erasing a block causes all the bytes to be set to 0xFF. Because of this restriction, modifying a block is not an atomic operation; power loss in the middle of this process can cause the contents of the block currently being updated to be in an unpredictable state. Since in most cases the original content of each block is needed in order to perform the update, the block which was being updated when the interruption occurred cannot be reconstructed. It is therefore advantageous to provide methods for fault tolerant FOTA update so that the update client can recover from power loss and resume the update successfully.
To ensure that the update process can continue from the point of interruption, the update engine performs an extra step before erasing and writing a block. Before erasing and writing a block, the update engine first writes the modified content to a backup (or temporary) block first. Once the content has been written to the backup block, it is safe for the update engine to erase and write the modified content to the block to be updated. If a power failure occurs after the erase but before the write completes, the update engine can recover by reading the modified content from the backup block.
Alternatively, the update engine could write the original content to the backup block. In this case, if a power failure occurs after the erase but before the write completes, the update engine can recover by reading the original content from the backup block and applying the update again to obtain the modified content.
In either case, however, the update engine performs an extra write operation whenever the update engine updates a block of the firmware image. These extra write operations increase linearly with the size of the number of blocks to be updated. The extra operations increase the amount of time needed for the update process to occur. It is therefore desirable to reduce the number of unnecessary backup operations during the updated process.